package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.PlatformProductDetail;

public class PlatformProductDetailWrapper {
	
	SqlManager manager;

    public PlatformProductDetailWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public PlatformProductDetail selectByPrimaryKey(long id) {
    	
    	PlatformProductDetail platformProductDetail = null;
    	
    	List<PlatformProductDetail> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.PlatformProductDetailMapper.selectByPrimaryKey",
                        id);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("platform_product_detail没有数据");
		}
		else 
			platformProductDetail = result.get(0);
		
		return platformProductDetail;
    }
    
    @SuppressWarnings("unchecked")
	public List<PlatformProductDetail> selectByOrderId(long orderId) {
    	
    	List<PlatformProductDetail> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.PlatformProductDetailMapper.selectByOrderId",
                        orderId);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("platform_product_detail没有数据");
			
			return null;
		}
		
		return result;
    }
    
    @SuppressWarnings("unchecked")
	public PlatformProductDetail selectByOrderIdAndCatalogId(long orderId, String catalogId) {
    	
    	PlatformProductDetail platformProductDetail = null;
    	
    	HashMap<String, Object> map = new HashMap<>();
    	
    	map.put("order_id", orderId);
    	map.put("catalog_id", catalogId);
    	
    	List<PlatformProductDetail> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.PlatformProductDetailMapper.selectByOrderIdAndCatalogId",
                        map);
        manager.commit();
        
        if (result.size() == 0) {
			Logger.comment("platform_product_detail没有数据");
		}
		else 
			platformProductDetail = result.get(0);
		
		return platformProductDetail;
    }
    
	public static void main(String[] args) {
		PlatformProductDetailWrapper wrapper = new PlatformProductDetailWrapper();
		Logger.debug(wrapper.selectByOrderIdAndCatalogId(14175098699L, "c9470586").getOrder_id());
	}
}
